#pragma once
#include "BreakDetector.h"
#include "WorkCycle.h"

class WorkSchedulingLogic
{
public:
	WorkSchedulingLogic();
	~WorkSchedulingLogic();

	enum eWorkState
	{
		STATE_STOPPED = 0,
		STATE_WORKING = 1,
		STATE_ON_BREAK = 2
	};

	void SetMaxWorkTime(CTimeSpan &workTimeSpan);
	void StartWork();
	void StopWork();
	void PauseWork();
	void Tick();
	eWorkState GetState();
	CTimeSpan TimeTillBreak();
	bool ShouldTakeBreak();
	void SetIdleThresholdSeconds(int seconds);
	int GetIdleThreasholdSeconds() const;
	void SetCompensateForIdleThreshold(bool bCompensate);//deduct idle threshold time when computing work cycle end time
	bool GetCompensateForIdleThreshold();

	std::list<WorkCycle> GetWorkCycles();

private:
	void EndWorkCycle(WorkCycle& workCycle);
	BreakDetector m_breakDetector;
	CTimeSpan m_maxWorkTimeSpan;
	std::list<WorkCycle> m_lstWorkCycles;
	bool m_bShouldTakeBreak;
	eWorkState m_state;
	bool m_bCompensateForIdleThreshold;
};
